import VueRouter from "vue-router";

const routes = [
    {
        path:'/',
        name:'login',
        component:()=>import('../Login')
    },
    // {
    //     path:'/crewlist',
    //     name:'crewlist',
    //     component:()=>import('../components/admin/CrewList.vue')
    // },
    {
        path:'/register',
        name:'register',
        component:()=>import('../Register')
    },
    {
        path:'/admin',
        name:'MyIndex',
        component:()=>import('../components/admin/MyIndex'),
        meta: { requiresAuth: true, requiresRole: 'ROLE_ADMIN' }, // 路由守卫
        children:[
            {
                path:'/',
                name:'user',
                component:()=>import('../components/admin/User.vue'),
                
            },
            {
                path:'/order',
                name:'test',
                component:()=>import('../components/admin/Order.vue'),
                // meta: {
                //     requiresAuth: true,
                //     isAuthenticated: true // 需要登录后访问的路由
                //   }
            }, 
        ]
    },
    {
        path:'/user',
        name:'userindex',
        component:()=>import('../components/user/MyIndex'),
        meta: { requiresAuth: true, requiresRole: 'ROLE_USER' },
        children:[
            {
                path:'/',
                name:'order',
                component:()=>import('../components/user/Order.vue'),
                
            }
        ]
    },
    {
      path: '/401',
      name: '401',
      component:()=>import('../components/Error401.vue'),
    },

]

const router = new VueRouter(
    {
        mode:'history',
        routes
    }
)

export default router